package cn.myzf.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.PropertySource;
import cn.myzf.server.typeServer.TCPServer;


import java.util.ArrayList;
import java.util.List;


/**
 * 服务器启动类
 *
 * @param
 * @Author: myzf
 * @Date: 2019/2/23 13:00
 */
@SpringBootApplication
@PropertySource(value = "classpath:/application.properties")
public class ServerApplication {

    public static void main(String[] args) throws Exception {

        //SpringApplication.run(ServerApplication.class, args);
        ConfigurableApplicationContext context = SpringApplication.run(ServerApplication.class, args);
        TCPServer tcpServer = context.getBean(TCPServer.class);
        openBrowse("http://localhost:10003/monitor.do");
        tcpServer.start();


    }


    /**
     * @param url 要打开的网址
     * @title 使用默认浏览器打开
     */
    private static void openBrowse(String url) throws Exception {
        List<String> list = new ArrayList<String>();
        list.add("cmd");
        list.add("/c");
        list.add("start");
        list.add(url);
        list.toArray();
        Runtime.getRuntime().exec(list.toArray(new String[0]));

    }


}